package com.neu.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.po.ResponseResult;
import com.neu.po.Salesman;
import com.neu.service.SalesmanService;

@RestController
@RequestMapping("salesman")
public class SalesmanController {

	@Autowired
	private SalesmanService salesmanService;
	
	@RequestMapping("getPaged")
	public ResponseResult getPaged(int pageNum,int pageSize,String keyword) {
		ResponseResult result = new ResponseResult();
		
		result.setData(salesmanService.getPaged(pageNum, pageSize, keyword));
		
		return result;
	}
	
	@RequestMapping("getAll")
	public ResponseResult getAll() {
		ResponseResult result = new ResponseResult();
		
		result.setData(salesmanService.getAll());
		
		return result;
	}
	
	@RequestMapping("update")
	public ResponseResult update(@RequestBody Salesman salesman) {
		ResponseResult result = new ResponseResult();

		result.setData(salesmanService.update(salesman));
		return result;
	}
	
	@RequestMapping("insert")
	public ResponseResult insert(@RequestBody Salesman salesman) {
		ResponseResult result = new ResponseResult();
		result.setData(salesmanService.insert(salesman));
		return result;
	}
	
	@RequestMapping("getAllCustomer")
	public ResponseResult getAllCustomer() {
		ResponseResult result = new ResponseResult();
		result.setData(salesmanService.getAllCustomer());
		return result;
	}
	
	@RequestMapping("delete")
	public ResponseResult delete(int id) {
		ResponseResult result = new ResponseResult();
		result.setData(salesmanService.delete(id));
		return result;
	}
}
